-
Notifications
You must be signed in to change notification settings - Fork 277
Support alpha in hexadecimal colors #3052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
d0b078e
to
83e8167
Compare
webapp/src/Utils/Utils.php
Outdated
*/ | ||
public static function parseHexColor(string $hex): array | ||
{ | ||
// Ignore alpha in hexstrings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why silently ignore the alpha channel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might indeed a bit harsh to do this silently. Do we ever think we need the alpha channel? Otherwise I think I'll add a optional boolean for this behaviour (optionally also returning rgba
instead of rgb
), alternative is to check all calling functions and handle this there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unlikely that we need it. But I'm either for supporting it properly or not allowing it at all to avoid user confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec allows for sending such a string "#ff00ffaa" so we need to store it. I think my fix already makes that we never pick it up but I'll think about this some more. Maybe just supporting it is easier in that case.
5369d0c
to
f4e085c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next to my minor comment, there are some phpcs errors left to fix. Otherwise good to merge.
No functional change intended.
1386766
to
d4e80ec
Compare
And add some more testing for those to also check for DOMjudge#123 format. The functions using the strings have moved from the TwigExtension to utils as the they don't really depend on Twig itself. This makes testing easier and can use this in the future for other elements. Co-authored-by: Tobias Werth <spam-by-github@never-mind.eu>
The contest validation breaks when the contestproblem has an invalid color PC^2 doesn't check the colors as they don't need them so mistakes in the problemset.yaml would also be fed to the feed.
This reverts commit b0b2b6e2ca30ea04d340f04ceb7a9eaee40b60f0.
This reverts commit 0353b080d18cfe7aeeefea96aad42d2247376ea0.
The Alpha is allowed by the CLICS spec but we don't really use those in the UI normally. The only place where we have to fully ignore the alpha is for the luminance. In that case we now by default merge it with a white background most likely this will be the same for either background but this was not tested. As bonus we now also test for the shorthand (#ABC) versuse (#AABBCC). The functions using the strings have moved from the TwigExtension to utils as the they don't really depend on Twig itself. This makes testing easier and can use this in the future for other elements. Co-authored-by: Tobias Werth <spam-by-github@never-mind.eu>
This reverts commit f231b96.
This reverts commit 9afb95b.
d4e80ec
to
c5bc5f1
Compare
This is as a basis to detect problematic colors coming from the primary.
I can't think of any place where any consumer would ever want to display the colors with some opacity. So I wonder if it's intentional that the spec links to a document which has this.